home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan / Opus 5 - Magellan.iso / DOpus_Install / ARexx / ARexx / ArrangeListers.dopus5 < prev    next >
Text File  |  1996-06-05  |  3KB  |  119 lines

  1. /*
  2.   $VER: ArrangeListers.dopus5 1.3 (13.5.96)
  3.   Written by Edmund Vermeulen (edmundv@grafix.xs4all.nl).
  4.  
  5.   ARexx script for Directory Opus 5.5 to arrange all listers into two neat
  6.   rows in an area that is defined by setting all four margins.
  7.  
  8.   This allows you to for example leave visible the drive icons on the left
  9.   hand side, or a button bank at the bottom. The source lister is always
  10.   placed at the top left while the destination lister is always placed at
  11.   the top right.
  12.  
  13.   Function : ARexx      DOpus5:ARexx/ArrangeListers.dopus5 {Qp} 110 0 0 0
  14.  
  15.   The four numbers at the end are the left, right, top and bottom margins.
  16. */
  17.  
  18. horspace=0    /* horizontal space between listers */
  19. verspace=0    /* vertical space between listers */
  20. ratio=50/50    /* ratio between left and right lister width */
  21.  
  22. parse arg portname leftmargin rightmargin topmargin bottommargin .
  23.  
  24. if portname=''|leftmargin=''|rightmargin=''|topmargin=''|bottommargin='' then do
  25.    address dopus.1 
  26.    lf='0a'x
  27.    dopus request '"ArrangeListers.dopus5 is not properly installed.'lf||lf||,
  28.       'Please read the installation instructions'lf||,
  29.       'at the top of the script." Read'
  30.    command read 'DOpus5:ARexx/ArrangeListers.dopus5'
  31.    exit
  32.    end
  33.  
  34. address value portname
  35. options results
  36. options failat 21
  37.  
  38. dopus screen
  39. parse var result . width height . barheight .
  40. topmargin=topmargin+barheight+1
  41.  
  42. lister query all
  43. if rc>0 then
  44.    exit
  45. allhandles=result
  46.  
  47. n=-1
  48. do while allhandles~=''
  49.    parse var allhandles thishandle allhandles
  50.    lister query thishandle visible
  51.    if result then do
  52.       n=n+1
  53.       handle.n=thishandle
  54.       end
  55.    end
  56. handle.count=n+1
  57. if handle.count=0 then
  58.    exit
  59.  
  60. half=handle.count%2
  61.  
  62. lister query source
  63. if rc=0 then do
  64.    parse var result srchandle .
  65.    do i=0 to handle.count-1
  66.       if handle.i=srchandle then do
  67.          handle.i=handle.0
  68.          handle.0=srchandle
  69.          leave
  70.          end
  71.       end
  72.    end
  73.  
  74. lister query dest
  75. if rc=0 then do
  76.    parse var result desthandle .
  77.    do i=0 to handle.count-1
  78.       if handle.i=desthandle then do
  79.          handle.i=handle.half
  80.          handle.half=desthandle
  81.          leave
  82.          end
  83.       end
  84.    end
  85.  
  86. rightwidth=(width-rightmargin-leftmargin-horspace)%(ratio+1)
  87. leftwidth=width-rightmargin-leftmargin-horspace-rightwidth
  88. rightpos=leftmargin+leftwidth+horspace
  89.  
  90. half2=(handle.count+1)%2
  91. listerheight=(height-topmargin-bottommargin-(half2-1)*verspace)%half2
  92. leftover=(height-topmargin-bottommargin-(half2-1)*verspace)//half2
  93.  
  94. onebigger=handle.count>2&handle.count//2>0
  95. oneleft=handle.count=1&handle.0~=desthandle
  96.  
  97. y=topmargin
  98. do i=0 to half-1+oneleft
  99.    h=listerheight
  100.    if i=0 & onebigger then do
  101.       h=2*h+verspace
  102.       if leftover>0 then
  103.          h=h+1
  104.       end
  105.    if i<leftover-onebigger then
  106.       h=h+1
  107.    lister set handle.i position leftmargin'/'y'/'leftwidth'/'h
  108.    y=y+h+verspace
  109.    end
  110.  
  111. y=topmargin
  112. do i=half+oneleft to handle.count-1
  113.    h=listerheight
  114.    if i-half<leftover then
  115.       h=h+1
  116.    lister set handle.i position rightpos'/'y'/'rightwidth'/'h
  117.    y=y+h+verspace
  118.    end
  119.